﻿using System;
using System.Collections.Generic;
using System.Text;
using NetworkLib.Utilities;

namespace PokemonBattle.BattleNetwork
{
    public enum BattleTerrain : int
    {
        Stadium = -1444406344,
        Grass = 372943555,
        Flat = -803934465,
        Sand = 835293505,
        Mountain = 984446105,
        Cave = -1859589031,
        Water = 78692563,
        SnowField = -1106010300,
        WrongInput = -1
    }
    public static class BattleTerrainHelper
    {
        public static BattleTerrain ReadFromByteArray(ByteArray byteArray)
        {
            int val = byteArray.ReadInt();
            return Parse(val);
        }
        public static BattleTerrain Parse(int val)
        {
            foreach (int value in Enum.GetValues(typeof(BattleTerrain)))
            {
                if (value == val) return (BattleTerrain)value;
            }
            return BattleTerrain.WrongInput;
        }

        public static void WriteToByteArray(ByteArray byteArray, BattleTerrain value)
        {
            byteArray.WriteInt((int)value);
        }
    }
}
